/**
 * YDUI 可伸缩布局方案
 * rem计算方式：设计图尺寸px / 100 = 实际rem  【例: 100px = 1rem，32px = .32rem】
 */
(function (window) {
  var doc = window.document
  var docEl = doc.documentElement
  var resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize'
  const DOCWIDTH = 1440
  var scrollTop = 0 // 滚动距离
  var recalc = (function refreshRem () {
    var clientWidth = docEl.getBoundingClientRect().width
    var targetWidth = 1440 * 1200 / 1365
    let name = window.location.href.split('/#/')[1]
    let noScale = ['zfSafetyProduction','zfEnergyConsumption','zfEnvironmentalProtection','zfParkManagement','tanpaifang','zfDiagnosticEvaluation','zfParkDetail','zfSafetyProduction2','zfPerMuBenefit','zfParkOverviewDetail']
    // let noScale1 = ['ChemicalIndustry','zfParkOverviewTwo','zfPerMuBenefitTwo','zfDiagnosticEvaluationTwo','zfIndustrialChainMap','zfSafetyOverviewTwo','zfDangerousGoodsTwo','zfEnvironmentalConservationTwo','zfContingencyManagementTwo','zfDataSharingTwo','home']
    if (clientWidth <= 1200 && !noScale.includes(name)) {
      // var bodyW = document.body.offsetWidth
      // var bodyW = document.body.scrollWidth
      var bodyW = 1250
      var scale = clientWidth / bodyW
      document.body.style.zoom = `${scale}`
      // document.body.style.transform = `scale(${scale})`
      // document.body.style.transformOrigin = `0 0`
    } else {
      document.body.style.transform = ``
      document.body.style.transformOrigin = `0 0`
      document.body.style.position = `relative`
    }
    docEl.style.fontSize = 20 * (targetWidth / DOCWIDTH) * 5 + 'px'
    return refreshRem
  })()
  if (!doc.addEventListener) return
  window.onload = function () {
    recalc()
  }
  // window.addEventListener('scroll',this.getScrollPosition,false)
  console.log(scrollTop)
  window.addEventListener(resizeEvt, recalc, false)
  doc.addEventListener('DOMContentLoaded', recalc, false)
}(window))
